package com.msc.mc.util;

import java.rmi.server.UID;
import java.util.Date;

import com.msc.sdm.ui.widget.util.CoreWidgetsUtils;

public class TestXML {
	public static void main(String[] args) {
		SimManagerImportBean importBean = new SimManagerImportBean();
		importBean.addParam("canEditDuringImport", "false");
		importBean.addParam("useOidDuringImport", "false");
		
		ObjectListBean bean  = importBean.addObjectList( "NIOMaterial" , "['objectId'=='123']", true );
		ObjectListBean bean1 = importBean.addObjectList( "NIOMatSpecification" , "['name'=='123']", true);
		ObjectListBean matSchemal = importBean.addObjectList( "MatMaterialsSchema" , "[name == 'NIODesignData']", true );
		
		Date now = new Date();
		String nowTime = Long.toHexString( now.getTime() );
		ObjectBean dsItem = importBean.addObject( "Item" );
		dsItem.addAttributeBean( "name" , "DS" + nowTime , "trueAndAutoAdjust" );
		
		ObjectBean dsVariant = importBean.addObject( "Variant" );
		dsVariant.addAttributeBean( "item" , dsItem.getId() , "false" );
		dsVariant.addAttributeBean( "name" , "V1" , "false" );
		
		ObjectBean dsBean = importBean.addObject( "MatDataSource" );
		dsBean.addAttributeBean( "name", "DS" + nowTime , "false" );
		dsBean.addAttributeBean( "schema", matSchemal.getId() , "false" );
		dsBean.addAttributeBean( "variant", dsVariant.getId() , "false" );
		

		ObjectBean designDataItem = importBean.addObject( "Item" );
		designDataItem.addAttributeBean( "name" , "2017-C1",  "trueAndAutoAdjust" );
		
		ObjectBean designDataVariant = importBean.addObject( "Variant" );
		designDataVariant.addAttributeBean( "item" , designDataItem.getId() ,  "false" );
		designDataVariant.addAttributeBean( "name" , "V1",  "false" );
		
		ObjectBean designDataBean = importBean.addObject( "NIODesignData" );
		designDataBean.addAttributeBean("name","value", "false" );
		designDataBean.addAttributeBean("matSpecNumber","2017-C1", "false" );
		designDataBean.addAttributeBean("materialSymbol","ABS", "false" );
		designDataBean.addAttributeBean("matId","123456", "false" );
		designDataBean.addAttributeBean("description","New NIO Design Data", "false" );
		
		designDataBean.addAttributeBean("variant" , designDataVariant.getId() , "false" );
		designDataBean.addAttributeBean("generatedFromModel", dsBean.getId() , "false" );//TODO
		//designDataBean.addAttributeBean("generatedFromObject","", "false" );//TODO
		//designDataBean.addAttributeBean("matRevisableProperties","", "false" );//TODO
		
		String message = importBean.getXMLString();
		//File file  = importBean.getXMLFile("/data/", "test.xml");
		
		System.out.println(message);
 
		UID uID = new UID();
		String string = uID.toString();
		string = string.replace(":", "_");
		string = string.replace("-", "_");
		System.out.println( string );
		uID = new UID();
		string = uID.toString();
		string = string.replace(":", "_");
		string = string.replace("-", "_");	
		System.out.println( string );
		uID = new UID();
		string = uID.toString();
		string = string.replace(":", "_");
		string = string.replace("-", "_");	
		System.out.println( string );
		uID = new UID();
		string = uID.toString();
		string = string.replace(":", "_");
		string = string.replace("-", "_");	
		System.out.println( string );
		uID = new UID();
		string = uID.toString();
		string = string.replace(":", "_");
		string = string.replace("-", "_");	
		System.out.println( string );
		
		System.out.println( CoreWidgetsUtils.generateUnqiueWidgetName() );
		System.out.println( CoreWidgetsUtils.generateUnqiueWidgetName() );
	}
}
